<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>基层AI辅助诊断系统 - 患者管理</title>
    <!-- 引入Element Plus的样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css">
    <!-- 引入Vue 3 -->
    <script src="https://unpkg.com/vue@3"></script>
    <!-- 引入Element Plus组件库 -->
    <script src="https://unpkg.com/element-plus"></script>
    <!-- 引入中文语言包 -->
    <script src="https://unpkg.com/element-plus/dist/locale/zh-cn.min.js"></script>
    <style>
        /* 基础样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
            background: #FFFFFF;
            color: var(--text-primary);
            font-size: 14px;
            line-height: 1.5;
            margin: 0;
        }

        /* 色彩系统 - 基于HIS系统现代极简风设计规范 */
        :root {
            /* 主色调 */
            --primary: #0F6CBD;
            --primary-light: #D0E7FF;
            --primary-dark: #0A4F8D;
            
            /* 辅助色 */
            --success: #0F8A5F;
            --warning: #F59337;
            --error: #D13438;
            --info: #0078D4;
            
            /* 中性色 - 文字 */
            --text-primary: #1A1A1A;
            --text-secondary: #4D4D4D;
            --text-tertiary: #767676;
            --text-disabled: #A6A6A6;
            
            /* 中性色 - 边框与分割线 */
            --border-strong: #CCCCCC;
            --border-normal: #E0E0E0;
            --border-light: #F0F0F0;
            --divider: #F5F5F5;
            
            /* 中性色 - 背景 */
            --bg-primary: #FFFFFF;
            --bg-secondary: #F9F9F9;
            --bg-card: #FFFFFF;
            --bg-disabled: #F5F5F5;
            
            /* 医疗专业色 */
            --medical-critical: #B91C1C;
            --medical-abnormal: #F59E0B;
            --medical-normal: #10B981;
            --medical-pending: #3B82F6;
            --medical-completed: #9CA3AF;
            
            /* 间距系统 */
            --spacing-2: 2px;
            --spacing-4: 4px;
            --spacing-8: 8px;
            --spacing-12: 12px;
            --spacing-16: 16px;
            --spacing-24: 24px;
            --spacing-32: 32px;
            --spacing-40: 40px;
            --spacing-48: 48px;
            
            /* 字体大小 */
            --font-page-title: 20px;
            --font-card-title: 16px;
            --font-table-title: 14px;
            --font-body: 14px;
            --font-table: 13px;
            --font-small: 12px;
            
            /* 行高 */
            --line-height-title: 1.4;
            --line-height-body: 1.5;
            --line-height-table: 1.2;
            --line-height-form: 1.4;
            
            /* 圆角 */
            --radius-small: 2px;
            --radius-medium: 4px;
            
            /* 动画时间 */
            --transition-fast: 150ms;
            --transition-normal: 200ms;
            --transition-slow: 300ms;
            
            /* 导航统一宽度 */
            --nav-item-width: 140px;
        }

        [v-cloak] {
            display: none;
        }

        /* 布局容器 */
        .container {
            width: 100%;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            background-color: var(--bg-secondary);
        }

        /* 顶部导航栏 */
        .header {
            height: 60px;
            background-color: var(--bg-primary);
            border-bottom: 1px solid var(--border-normal);
            display: flex;
            align-items: center;
            padding: 0 var(--spacing-24);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
            position: relative;
            z-index: 100;
        }

        .header-spacer {
            width: 200px;
            flex-shrink: 0;
        }

        #app-nav {
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            z-index: 10;
            width: calc(100% - 400px); /* 两侧各200px 对称留白 */
            display: flex;
            justify-content: center;
        }
        
        /* Element Plus菜单样式覆盖 */
        .el-menu {
            border: none !important;
            background-color: transparent !important;
        }
        
        .el-menu--horizontal > .el-menu-item,
        .el-menu--horizontal > .el-sub-menu .el-sub-menu__title {
            height: 60px;
            line-height: 60px;
            color: var(--text-secondary);
            font-weight: 500;
            font-size: var(--font-body);
            padding: 0;
            width: var(--nav-item-width);
            text-align: center;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
        }

        .el-sub-menu__icon-arrow { display: none !important; }

        .el-menu--horizontal > .el-sub-menu .el-sub-menu__title::after {
            content: '';
            display: inline-block;
            width: 16px;
            height: 16px;
            margin-left: 8px;
            background-repeat: no-repeat;
            background-position: center;
            background-size: 16px 16px;
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23767676' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
        }

        .el-sub-menu:hover > .el-sub-menu__title::after,
        .el-sub-menu.is-active > .el-sub-menu__title::after {
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230F6CBD' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
        }

        .el-sub-menu.is-opened > .el-sub-menu__title::after {
            background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230F6CBD' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 15 12 9 18 15'/></svg>");
        }
        
        .el-menu--horizontal > .el-menu-item.is-active,
        .el-menu--horizontal > .el-sub-menu.is-active .el-sub-menu__title {
            color: var(--primary) !important;
            border-bottom: 2px solid var(--primary);
            font-weight: 500;
        }
        
        .el-menu--horizontal > .el-menu-item:not(.is-disabled):hover,
        .el-menu--horizontal > .el-menu-item:not(.is-disabled):focus,
        .el-menu--horizontal > .el-sub-menu:not(.is-disabled):hover .el-sub-menu__title {
            color: var(--primary);
            background-color: transparent;
        }
        
        /* 下拉菜单样式覆盖 */
        .el-menu--popup {
            width: var(--nav-item-width) !important;
            min-width: var(--nav-item-width) !important;
            max-width: var(--nav-item-width) !important;
            border-radius: var(--radius-small);
            padding: 4px 0;
            border: 1px solid var(--border-light);
            border-top: 2px solid var(--primary);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            text-align: center !important;
        }
        
        .el-menu--popup .el-menu-item {
            height: 36px;
            line-height: 36px;
            padding: 0 !important;
            color: var(--text-secondary);
            white-space: nowrap;
            text-align: center;
            width: var(--nav-item-width) !important;
            box-sizing: border-box;
            overflow: hidden;
            text-overflow: ellipsis;
            display: flex !important;
            justify-content: center !important;
            align-items: center !important;
            font-size: var(--font-body);
        }
        
        .el-menu--popup .el-menu-item:hover {
            background-color: var(--bg-secondary);
            color: var(--primary);
        }

        .user-section {
            display: flex;
            align-items: center;
            gap: var(--spacing-16);
            margin-left: auto;
            z-index: 10;
            width: 200px;
            justify-content: flex-end;
            flex-shrink: 0;
            cursor: pointer;
            padding: 8px 12px;
            border-radius: var(--radius-small);
            transition: background-color var(--transition-fast);
            color: var(--text-secondary);
        }

        .user-section:hover {
            background-color: var(--bg-secondary);
        }

        .user-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background-color: var(--primary-light);
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--primary);
            font-weight: 500;
        }

        .user-name {
            font-weight: 500;
            font-size: var(--font-body);
            color: var(--text-secondary);
        }

        .user-arrow {
            color: var(--text-tertiary);
            transition: color var(--transition-normal);
        }

        .user-section:hover .user-arrow {
            color: var(--primary);
        }

        /* 用户下拉弹窗 */
        .user-dropdown {
            position: absolute;
            top: 60px; /* 紧贴头部底部 */
            right: var(--spacing-24);
            width: 160px;
            background: var(--bg-primary);
            border: 1px solid var(--border-light);
            border-radius: var(--radius-small);
            box-shadow: 0 4px 12px rgba(0,0,0,0.08);
            display: none;
            z-index: 200;
            overflow: hidden;
        }

        .user-dropdown .item {
            padding: 10px 12px;
            color: var(--text-secondary);
            font-size: var(--font-body);
            cursor: pointer;
            white-space: nowrap;
        }

        .user-dropdown .item:hover {
            background-color: var(--bg-secondary);
            color: var(--primary);
        }

        /* 主要内容区域样式 */
        .main-content {
            padding: 0;
            flex: 1;
            background-color: var(--bg-primary);
            width: 100%;
        }
        
        .content-card {
            width: 100%;
            margin: 0;
            background: var(--bg-primary);
            border: none;
            border-radius: 0;
            box-shadow: none;
            display: flex;
            flex-direction: column;
        }

        /* 页面标题与操作区域样式 */
        .combined-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: var(--spacing-24);
            border-bottom: 1px solid var(--border-light);
            background-color: var(--bg-primary);
        }
        
        .page-title {
            font-size: var(--font-page-title);
            font-weight: 600;
            color: var(--text-primary);
            line-height: var(--line-height-title);
            margin-right: var(--spacing-24);
            white-space: nowrap;
        }

        .header-actions {
            display: flex;
            align-items: center;
            gap: var(--spacing-16);
        }

        /* 搜索框样式 */
        .search-box {
            position: relative;
            width: 240px;
        }
        
        .search-icon {
            position: absolute;
            left: 8px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-tertiary);
            pointer-events: none;
        }
        
        .search-box input {
            width: 100%;
            padding: var(--spacing-8) var(--spacing-8) var(--spacing-8) 32px;
            border: 1px solid var(--border-normal);
            border-radius: var(--radius-small);
            font-size: 14px;
            color: var(--text-primary);
            transition: border-color 0.2s, box-shadow 0.2s;
            height: 32px;
        }
        
        .search-box input:focus {
            border-color: var(--primary);
            outline: none;
            box-shadow: 0 0 0 2px rgba(15, 108, 189, 0.2);
        }
        
        .search-box input::placeholder {
            color: var(--text-tertiary);
        }

        /* 按钮样式 */
        .btn {
            padding: var(--spacing-8) var(--spacing-16);
            border-radius: var(--radius-small);
            font-size: var(--font-body);
            font-weight: 500;
            cursor: pointer;
            border: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: all var(--transition-normal);
            gap: var(--spacing-8);
            height: 32px;
            line-height: 1;
        }
        
        .btn .icon {
            flex-shrink: 0;
        }
        
        .btn-primary {
            background-color: var(--primary);
            color: white;
        }
        
        .btn-primary:hover {
            background-color: var(--primary-dark);
        }
        
        .btn-primary:active {
            background-color: var(--primary-dark);
            transform: translateY(1px);
        }
        
        .btn-default {
            background-color: var(--bg-primary);
            color: var(--text-secondary);
            border: 1px solid var(--border-normal);
        }
        
        .btn-default:hover {
            background-color: var(--bg-secondary);
        }
        
        .btn-default:active {
            background-color: var(--bg-secondary);
            transform: translateY(1px);
        }

        /* 表格区域样式 */
        .table-section {
            padding: var(--spacing-24);
            display: flex;
            flex-direction: column;
            gap: var(--spacing-24);
            background-color: var(--bg-primary);
        }

        /* 表格容器 */
        .table-container {
            background-color: var(--bg-primary);
            border-radius: var(--radius-small);
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
            overflow: auto;
            margin-bottom: var(--spacing-16);
            border: 1px solid var(--border-light);
        }
        
        .data-table {
            width: 100%;
            border-collapse: collapse;
        }
        
        .data-table th {
            background-color: var(--bg-secondary);
            padding: var(--spacing-12) var(--spacing-16);
            text-align: left;
            font-weight: 600;
            color: var(--text-secondary);
            border-bottom: 1px solid var(--border-normal);
            height: 40px;
            font-size: var(--font-table-title);
        }
        
        .data-table td {
            padding: var(--spacing-12) var(--spacing-16);
            border-bottom: 1px solid var(--border-light);
            color: var(--text-secondary);
            height: 40px;
            vertical-align: middle;
            font-size: var(--font-table);
        }
        
        .data-table tr:hover {
            background-color: var(--bg-secondary);
        }
        
        .data-table tr:last-child td {
            border-bottom: none;
        }

        /* 操作按钮样式 */
        .operations {
            display: inline-flex;
            gap: var(--spacing-8);
        }

        .operation-link {
            color: var(--primary);
            text-decoration: none;
        }

        .operation-link:hover {
            color: var(--primary-dark);
        }

        /* 空表格提示 */
        .empty-table-message {
            text-align: center;
            color: var(--text-tertiary);
            padding: var(--spacing-16);
            font-style: italic;
        }

        /* 表格底部区域 */
        .table-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: var(--spacing-16) var(--spacing-24);
        }

        /* 分页控件样式 */
        .pagination-text {
            color: var(--text-tertiary);
            font-size: var(--font-small);
        }

        .pagination-controls {
            display: flex;
            align-items: center;
            gap: var(--spacing-24);
        }

        .page-numbers {
            display: flex;
            gap: var(--spacing-8);
        }

        .page-numbers button {
            min-width: 32px;
            height: 32px;
            border-radius: var(--radius-small);
            border: 1px solid var(--border-normal);
            background: var(--bg-primary);
            cursor: pointer;
            color: var(--text-secondary);
            transition: all var(--transition-normal);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: var(--font-small);
        }

        .page-numbers button:hover {
            border-color: var(--primary);
            color: var(--primary);
        }

        .page-numbers button.active {
            background: var(--primary);
            border-color: var(--primary);
            color: #FFFFFF;
        }

        .pagination-size {
            display: flex;
            align-items: center;
            gap: var(--spacing-8);
            color: var(--text-secondary);
            font-size: var(--font-small);
        }

        .page-size-selector {
            height: 32px;
            border: 1px solid var(--border-normal);
            border-radius: var(--radius-small);
            padding: 0 var(--spacing-8);
            font-size: var(--font-small);
            margin: 0 var(--spacing-4);
        }

        /* 弹窗样式 */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(0, 0, 0, 0.5);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            display: none;
        }
        
        .modal {
            background-color: var(--bg-primary);
            border-radius: var(--radius-small);
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
            width: 500px;
            max-width: 90%;
            max-height: 90vh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        
        .modal-header {
            padding: var(--spacing-16) var(--spacing-24);
            border-bottom: 1px solid var(--border-light);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        
        .modal-title {
            font-size: var(--font-card-title);
            font-weight: 600;
            color: var(--text-primary);
        }
        
        .modal-close {
            background: none;
            border: none;
            cursor: pointer;
            color: var(--text-tertiary);
            font-size: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            border-radius: 50%;
        }
        
        .modal-close:hover {
            background-color: var(--bg-secondary);
            color: var(--text-secondary);
        }
        
        .modal-body {
            padding: var(--spacing-24);
            overflow-y: auto;
        }
        
        .modal-footer {
            padding: var(--spacing-16) var(--spacing-24);
            border-top: 1px solid var(--border-light);
            display: flex;
            justify-content: flex-end;
            gap: var(--spacing-16);
        }

        /* 表单样式 */
        .form-group {
            margin-bottom: var(--spacing-16);
        }
        
        .form-group:last-child {
            margin-bottom: 0;
        }
        
        .form-label {
            display: block;
            margin-bottom: var(--spacing-8);
            font-weight: 500;
            color: var(--text-secondary);
        }
        
        .form-label .required {
            color: var(--error);
            margin-left: 4px;
        }
        
        .form-control {
            width: 100%;
            padding: var(--spacing-8) var(--spacing-12);
            border: 1px solid var(--border-normal);
            border-radius: var(--radius-small);
            font-size: var(--font-body);
            color: var(--text-primary);
            transition: border-color var(--transition-normal);
            height: 36px;
        }
        
        .form-control:focus {
            border-color: var(--primary);
            outline: none;
            box-shadow: 0 0 0 2px rgba(15, 108, 189, 0.2);
        }
        
        .form-control::placeholder {
            color: var(--text-tertiary);
        }
        
        textarea.form-control {
            height: auto;
            min-height: 80px;
            resize: vertical;
        }
        
        .form-row {
            display: flex;
            gap: var(--spacing-16);
            margin-bottom: var(--spacing-16);
        }
        
        .form-col {
            flex: 1;
        }
        
        .radio-group {
            display: flex;
            gap: var(--spacing-16);
            margin-top: var(--spacing-8);
        }
        
        .radio-label {
            display: flex;
            align-items: center;
            gap: var(--spacing-8);
            cursor: pointer;
        }

        /* 确认删除弹窗样式 */
        .confirm-dialog {
            text-align: center;
            padding: var(--spacing-24);
        }
        
        .confirm-message {
            margin-bottom: var(--spacing-16);
            color: var(--text-primary);
        }
        
        .confirm-warning {
            color: var(--text-tertiary);
            font-size: var(--font-small);
            margin-bottom: var(--spacing-24);
        }
        
        .confirm-actions {
            display: flex;
            justify-content: center;
            gap: var(--spacing-16);
        }
        
        .btn-danger {
            background-color: var(--error);
            color: white;
        }
        
        .btn-danger:hover {
            background-color: #b71c1c;
        }

        /* 响应式样式 */
        @media (max-width: 768px) {
            .header {
                flex-wrap: wrap;
                padding: var(--spacing-12) var(--spacing-16);
                height: auto;
            }
            
            .header-spacer {
                width: 100%;
                justify-content: center;
                margin-bottom: 8px;
            }
            
            .user-section {
                width: 100%;
                justify-content: center;
                order: 3;
                margin-top: 8px;
            }
            
            #app-nav {
                position: relative;
                left: 0;
                transform: none;
                width: 100%;
                order: 3;
                margin-top: var(--spacing-8);
            }
            
            /* Element Plus移动端菜单样式覆盖 */
            .el-menu--collapse {
                width: 100%;
            }
            
            .el-menu--horizontal {
                flex-wrap: wrap;
                width: 100%;
                overflow-x: auto;
                white-space: nowrap;
                -webkit-overflow-scrolling: touch;
                padding-bottom: var(--spacing-4);
                justify-content: center;
            }
            
            .el-menu--horizontal > .el-menu-item,
            .el-menu--horizontal > .el-sub-menu .el-sub-menu__title {
                height: 48px;
                line-height: 48px;
            }
            
            /* 移动端下拉菜单样式 */
            .el-menu--popup {
                position: fixed;
                top: auto !important;
                left: 0 !important;
                right: 0 !important;
                width: 100%;
                max-height: 60vh;
                overflow-y: auto;
                border-radius: 8px 8px 0 0;
            }
            
            .main-content {
                padding: 0;
            }
            
            .combined-header {
                flex-direction: column;
                align-items: flex-start;
                gap: var(--spacing-16);
            }
            
            .page-title {
                margin-bottom: var(--spacing-8);
            }
            
            .header-actions {
                width: 100%;
                flex-direction: column;
                gap: var(--spacing-12);
            }
            
            .search-box {
                width: 100%;
            }
            
            .table-container {
                overflow-x: auto;
            }
            
            .data-table {
                min-width: 800px;
            }
            
            .table-footer {
                flex-direction: column;
                gap: var(--spacing-16);
                align-items: flex-start;
            }
            
            .pagination-controls {
                flex-direction: column;
                gap: var(--spacing-16);
                align-items: flex-start;
                width: 100%;
            }
            
            .page-numbers {
                flex-wrap: wrap;
                justify-content: flex-start;
                width: 100%;
            }
            
            .form-row {
                flex-direction: column;
                gap: var(--spacing-12);
            }
        }
    </style>
</head>
<body>
    <div id="app" class="container">
        <!-- 顶部导航栏 - 使用Element Plus组件 -->
        <header class="header">
            <div class="header-spacer"></div>
            <div id="app-nav">
                <el-menu 
                    :default-active="activeIndex" 
                    class="el-menu-demo" 
                    mode="horizontal" 
                    @select="handleSelect"
                    :ellipsis="false"
                    :popper-offset="0"
                    popper-class="custom-dropdown">
                    <el-menu-item index="1">开始问诊</el-menu-item>
                    <el-sub-menu index="2" popper-class="custom-dropdown">
                        <template #title>病历管理</template>
                        <el-menu-item index="2-1">病历查询</el-menu-item>
                        <el-menu-item index="2-2">病历模板</el-menu-item>
                        <el-menu-item index="2-3">个人药品</el-menu-item>
                    </el-sub-menu>
                    <el-menu-item index="3">患者管理</el-menu-item>
                    <el-sub-menu index="4" popper-class="custom-dropdown">
                        <template #title>数据统计</template>
                        <el-menu-item index="4-1">诊断统计</el-menu-item>
                        <el-menu-item index="4-2">宏观统计</el-menu-item>
                    </el-sub-menu>
                    <el-menu-item index="5">医学知识</el-menu-item>
                    <el-sub-menu index="6" popper-class="custom-dropdown">
                        <template #title>基础数据</template>
                        <el-menu-item index="6-1">药品管理</el-menu-item>
                    </el-sub-menu>
                    <el-sub-menu index="7" popper-class="custom-dropdown">
                        <template #title>消息通知</template>
                        <el-menu-item index="7-1">通知查看</el-menu-item>
                        <el-menu-item index="7-2">通知发布</el-menu-item>
                    </el-sub-menu>
                    <el-sub-menu index="8" popper-class="custom-dropdown">
                        <template #title>用户管理</template>
                        <el-menu-item index="8-1">用户管理</el-menu-item>
                        <el-menu-item index="8-2">角色管理</el-menu-item>
                    </el-sub-menu>
                </el-menu>
            </div>
            <div class="user-section" id="userSection">
                <span class="user-name">张医生</span>
                <svg class="user-arrow" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                    <polyline points="6 9 12 15 18 9"></polyline>
                </svg>
            </div>
            <div class="user-dropdown" id="userDropdown">
                <div class="item">个人中心</div>
                <div class="item">退出登录</div>
            </div>
        </header>
        <div class="main-content">
            <div class="content-card">
                <!-- 页面标题与操作区域 -->
                <section class="combined-header">
                    <h1 class="page-title">患者管理</h1>
                    <div class="header-actions">
                        <div class="search-box">
                            <svg class="search-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                <circle cx="11" cy="11" r="8"></circle>
                                <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
                            </svg>
                            <input type="text" id="searchInput" placeholder="搜索患者姓名、身份证号或电话">
                        </div>
                        <button id="searchBtn" class="btn btn-primary">搜索</button>
                        <button id="addPatientBtn" class="btn btn-primary">新增患者</button>
                    </div>
                </section>
                
                <!-- 患者列表区域 -->
                <section class="table-section">
                    <div class="table-container">
                        <table class="data-table">
                            <thead>
                                <tr>
                                    <th>姓名</th>
                                    <th>性别</th>
                                    <th>年龄</th>
                                    <th>电话</th>
                                    <th>身份证号</th>
                                    <th>最近就诊</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody id="patientBody">
                                <!-- 表格内容将通过JavaScript动态生成 -->
                            </tbody>
                        </table>
                    </div>
                    <div class="table-footer">
                        <div class="pagination-text" id="summaryText">共 <span id="totalRecords">50</span> 条记录</div>
                        <div class="pagination-controls">
                            <div id="pageNumbers" class="page-numbers">
                                <button class="active">1</button>
                                <button>2</button>
                                <button>3</button>
                                <button>4</button>
                                <button>5</button>
                            </div>
                            <div class="pagination-size">
                                每页显示
                                <select id="pageSizeSelector" class="page-size-selector">
                                    <option value="10">10</option>
                                    <option value="20">20</option>
                                    <option value="50">50</option>
                                </select>
                                条
                            </div>
                        </div>
                    </div>
                </section>
            </div>
        </div>
        
        <!-- 患者新增/编辑弹窗 -->
        <div class="modal-overlay" id="patientModalOverlay">
            <div class="modal">
                <div class="modal-header">
                    <h3 class="modal-title" id="modalTitle">患者信息编辑</h3>
                    <button class="modal-close" id="modalClose">&times;</button>
                </div>
                <div class="modal-body">
                    <form id="patientForm">
                        <div class="form-group">
                            <label class="form-label">基本信息</label>
                            <hr style="border: none; border-top: 1px solid var(--border-light); margin-bottom: 16px;">
                        </div>
                        
                        <div class="form-group">
                            <label class="form-label" for="patientName">姓名 <span class="required">*</span></label>
                            <input type="text" id="patientName" class="form-control" required>
                        </div>
                        
                        <div class="form-row">
                            <div class="form-col">
                                <label class="form-label">性别 <span class="required">*</span></label>
                                <div class="radio-group">
                                    <label class="radio-label">
                                        <input type="radio" name="gender" value="男" checked> 男
                                    </label>
                                    <label class="radio-label">
                                        <input type="radio" name="gender" value="女"> 女
                                    </label>
                                </div>
                            </div>
                            <div class="form-col">
                                <label class="form-label" for="birthDate">出生日期</label>
                                <input type="date" id="birthDate" class="form-control">
                            </div>
                        </div>
                        
                        <div class="form-row">
                            <div class="form-col">
                                <label class="form-label" for="patientAge">年龄</label>
                                <input type="number" id="patientAge" class="form-control">
                            </div>
                            <div class="form-col">
                                <label class="form-label" for="patientId">身份证号</label>
                                <input type="text" id="patientId" class="form-control">
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label class="form-label">联系方式</label>
                            <hr style="border: none; border-top: 1px solid var(--border-light); margin-bottom: 16px;">
                        </div>
                        
                        <div class="form-group">
                            <label class="form-label" for="patientPhone">联系电话 <span class="required">*</span></label>
                            <input type="tel" id="patientPhone" class="form-control" required>
                        </div>
                        
                        <div class="form-group">
                            <label class="form-label" for="patientAddress">住址</label>
                            <input type="text" id="patientAddress" class="form-control">
                        </div>
                        
                        <div class="form-group">
                            <label class="form-label" for="patientNote">备注</label>
                            <textarea id="patientNote" class="form-control"></textarea>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-default" id="cancelBtn">取消</button>
                    <button class="btn btn-primary" id="saveBtn">保存</button>
                </div>
            </div>
        </div>
        
        <!-- 删除确认弹窗 -->
        <div class="modal-overlay" id="deleteModalOverlay">
            <div class="modal" style="width: 400px;">
                <div class="modal-header">
                    <h3 class="modal-title">确认删除</h3>
                    <button class="modal-close" id="deleteModalClose">&times;</button>
                </div>
                <div class="modal-body">
                    <div class="confirm-dialog">
                        <p class="confirm-message">确定要删除患者"<span id="deletePatientName">张三</span>"的信息吗？</p>
                        <p class="confirm-warning">此操作不可恢复。</p>
                    </div>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-default" id="cancelDeleteBtn">取消</button>
                    <button class="btn btn-danger" id="confirmDeleteBtn">确定删除</button>
                </div>
            </div>
        </div>
    </div>
    <script>
        // 创建Vue应用
        document.addEventListener('DOMContentLoaded', function() {
            const { createApp, ref } = Vue;
            
            // 创建导航菜单Vue应用
            const navApp = createApp({
                setup() {
                    const activeIndex = ref('3'); // 默认选中"患者管理"
                    
                    const handleSelect = (key, keyPath) => {
                        console.log(key, keyPath);
                        // 这里可以添加导航逻辑，如页面跳转等
                    };
                    
                    return {
                        activeIndex,
                        handleSelect
                    };
                }
            });
            
            // 使用Element Plus
            navApp.use(ElementPlus, {
                locale: ElementPlusLocaleZhCn
            });
            
            // 挂载Vue应用
            navApp.mount('#app-nav');

            // 模拟患者数据
            const patients = [
                { id: '001', name: '张三', gender: '男', age: '45', phone: '13812345678', idCard: '330122198001010011', lastVisit: '2025-09-25', address: '上海市浦东新区张江高科技园区', note: '高血压患者，需定期复查' },
                { id: '002', name: '李四', gender: '女', age: '32', phone: '13912345678', idCard: '440103199201020022', lastVisit: '2025-09-20', address: '广州市天河区天河路123号', note: '' },
                { id: '003', name: '王五', gender: '男', age: '67', phone: '13512345678', idCard: '360102195801010033', lastVisit: '2025-09-18', address: '南昌市东湖区八一大道456号', note: '糖尿病患者' },
                { id: '004', name: '赵六', gender: '女', age: '28', phone: '13712345678', idCard: '320102199701010044', lastVisit: '2025-09-15', address: '南京市鼓楼区中山北路789号', note: '' },
                { id: '005', name: '钱七', gender: '男', age: '56', phone: '13612345678', idCard: '350102196901010055', lastVisit: '2025-09-10', address: '福州市鼓楼区五四路101号', note: '高血脂' }
            ];

            // 获取DOM元素
            const searchInput = document.getElementById('searchInput');
            const searchBtn = document.getElementById('searchBtn');
            const addPatientBtn = document.getElementById('addPatientBtn');
            const patientBody = document.getElementById('patientBody');
            const totalRecordsEl = document.getElementById('totalRecords');
            
            // 分页相关元素
            const pageNumbersEl = document.getElementById('pageNumbers');
            const pageSizeSelector = document.getElementById('pageSizeSelector');
            
            // 弹窗相关元素
            const patientModalOverlay = document.getElementById('patientModalOverlay');
            const modalClose = document.getElementById('modalClose');
            const modalTitle = document.getElementById('modalTitle');
            const patientForm = document.getElementById('patientForm');
            const saveBtn = document.getElementById('saveBtn');
            const cancelBtn = document.getElementById('cancelBtn');
            
            // 删除确认弹窗相关元素
            const deleteModalOverlay = document.getElementById('deleteModalOverlay');
            const deleteModalClose = document.getElementById('deleteModalClose');
            const deletePatientName = document.getElementById('deletePatientName');
            const confirmDeleteBtn = document.getElementById('confirmDeleteBtn');
            const cancelDeleteBtn = document.getElementById('cancelDeleteBtn');

            // 表单字段元素
            const patientNameInput = document.getElementById('patientName');
            const patientAgeInput = document.getElementById('patientAge');
            const birthDateInput = document.getElementById('birthDate');
            const patientIdInput = document.getElementById('patientId');
            const patientPhoneInput = document.getElementById('patientPhone');
            const patientAddressInput = document.getElementById('patientAddress');
            const patientNoteInput = document.getElementById('patientNote');
            const genderInputs = document.getElementsByName('gender');

            // 分页状态
            let filtered = [...patients];
            let pageSize = 10;
            let currentPage = 1;
            let totalPages = Math.ceil(filtered.length / pageSize);
            
            // 当前编辑的患者ID
            let currentPatientId = null;
            // 当前要删除的患者ID
            let deletePatientId = null;

            // 渲染表格数据
            function renderTable() {
                // 计算当前页数据
                const start = (currentPage - 1) * pageSize;
                const end = start + pageSize;
                const pageData = filtered.slice(start, end);
                
                // 清空表格内容
                patientBody.innerHTML = '';
                
                // 如果没有数据，显示空表格提示
                if (pageData.length === 0) {
                    const emptyRow = document.createElement('tr');
                    emptyRow.innerHTML = `<td colspan="7" class="empty-table-message">暂无符合条件的患者记录</td>`;
                    patientBody.appendChild(emptyRow);
                } else {
                    // 渲染数据行
                    pageData.forEach(patient => {
                        const row = document.createElement('tr');
                        row.innerHTML = `
                            <td>${patient.name}</td>
                            <td>${patient.gender}</td>
                            <td>${patient.age}</td>
                            <td>${patient.phone}</td>
                            <td>${patient.idCard}</td>
                            <td>${patient.lastVisit}</td>
                            <td>
                                <div class="operations">
                                    <a class="operation-link" href="#" onclick="editPatient('${patient.id}')">编辑</a>
                                    <a class="operation-link" href="#" style="color:var(--error);" onclick="deletePatient('${patient.id}')">删除</a>
                                </div>
                            </td>
                        `;
                        patientBody.appendChild(row);
                    });
                }
                
                // 更新总记录数显示
                totalRecordsEl.textContent = filtered.length;
                
                // 更新分页控件
                renderPagination();
            }

            // 渲染分页控件
            function renderPagination() {
                totalPages = Math.ceil(filtered.length / pageSize);
                
                // 渲染页码按钮
                pageNumbersEl.innerHTML = '';
                
                // 计算需要显示的页码范围
                let startPage = Math.max(1, currentPage - 2);
                let endPage = Math.min(totalPages, startPage + 4);
                
                // 调整起始页，确保显示5个页码
                if (endPage - startPage < 4 && totalPages > 4) {
                    startPage = Math.max(1, endPage - 4);
                }
                
                // 创建页码按钮
                for (let i = startPage; i <= endPage; i++) {
                    const pageBtn = document.createElement('button');
                    pageBtn.textContent = i;
                    pageBtn.className = i === currentPage ? 'active' : '';
                    pageBtn.addEventListener('click', () => {
                        currentPage = i;
                        renderTable();
                    });
                    pageNumbersEl.appendChild(pageBtn);
                }
            }

            // 应用筛选条件
            function applyFilter() {
                const keyword = searchInput.value.trim().toLowerCase();
                
                filtered = patients.filter(patient => {
                    return !keyword || 
                        patient.name.toLowerCase().includes(keyword) || 
                        patient.idCard.toLowerCase().includes(keyword) || 
                        patient.phone.toLowerCase().includes(keyword);
                });
                
                // 重置为第一页并重新渲染
                currentPage = 1;
                renderTable();
            }

            // 打开患者编辑弹窗
            window.editPatient = function(id) {
                currentPatientId = id;
                modalTitle.textContent = "编辑患者信息";
                
                // 查找患者数据
                const patient = patients.find(p => p.id === id);
                if (patient) {
                    // 填充表单
                    patientNameInput.value = patient.name;
                    patientAgeInput.value = patient.age;
                    patientIdInput.value = patient.idCard;
                    patientPhoneInput.value = patient.phone;
                    patientAddressInput.value = patient.address;
                    patientNoteInput.value = patient.note;
                    
                    // 设置性别
                    for (const radio of genderInputs) {
                        if (radio.value === patient.gender) {
                            radio.checked = true;
                            break;
                        }
                    }
                    
                    // 计算出生日期（模拟）
                    const today = new Date();
                    const birthYear = today.getFullYear() - parseInt(patient.age);
                    birthDateInput.value = `${birthYear}-01-01`;
                }
                
                // 显示弹窗
                patientModalOverlay.style.display = 'flex';
            };

            // 打开新增患者弹窗
            function addPatient() {
                currentPatientId = null;
                modalTitle.textContent = "新增患者";
                
                // 重置表单
                patientForm.reset();
                
                // 显示弹窗
                patientModalOverlay.style.display = 'flex';
            }

            // 保存患者信息
            function savePatient() {
                // 表单验证
                if (!patientNameInput.value.trim()) {
                    alert("请输入患者姓名");
                    return;
                }
                
                if (!patientPhoneInput.value.trim()) {
                    alert("请输入联系电话");
                    return;
                }
                
                // 获取性别
                let selectedGender = "男";
                for (const radio of genderInputs) {
                    if (radio.checked) {
                        selectedGender = radio.value;
                        break;
                    }
                }
                
                if (currentPatientId) {
                    // 编辑现有患者
                    const index = patients.findIndex(p => p.id === currentPatientId);
                    if (index !== -1) {
                        patients[index] = {
                            ...patients[index],
                            name: patientNameInput.value.trim(),
                            gender: selectedGender,
                            age: patientAgeInput.value.trim(),
                            phone: patientPhoneInput.value.trim(),
                            idCard: patientIdInput.value.trim(),
                            address: patientAddressInput.value.trim(),
                            note: patientNoteInput.value.trim()
                        };
                    }
                } else {
                    // 添加新患者
                    const newId = (parseInt(patients[patients.length - 1].id) + 1).toString().padStart(3, '0');
                    patients.push({
                        id: newId,
                        name: patientNameInput.value.trim(),
                        gender: selectedGender,
                        age: patientAgeInput.value.trim(),
                        phone: patientPhoneInput.value.trim(),
                        idCard: patientIdInput.value.trim(),
                        lastVisit: '暂无就诊记录',
                        address: patientAddressInput.value.trim(),
                        note: patientNoteInput.value.trim()
                    });
                }
                
                // 关闭弹窗
                patientModalOverlay.style.display = 'none';
                
                // 重新应用筛选并渲染表格
                applyFilter();
            }

            // 打开删除确认弹窗
            window.deletePatient = function(id) {
                deletePatientId = id;
                
                // 查找患者数据
                const patient = patients.find(p => p.id === id);
                if (patient) {
                    deletePatientName.textContent = patient.name;
                }
                
                // 显示弹窗
                deleteModalOverlay.style.display = 'flex';
            };

            // 确认删除患者
            function confirmDelete() {
                if (deletePatientId) {
                    // 删除患者
                    const index = patients.findIndex(p => p.id === deletePatientId);
                    if (index !== -1) {
                        patients.splice(index, 1);
                    }
                    
                    // 关闭弹窗
                    deleteModalOverlay.style.display = 'none';
                    
                    // 重新应用筛选并渲染表格
                    applyFilter();
                }
            }

            // 绑定事件处理函数
            searchBtn.addEventListener('click', applyFilter);
            searchInput.addEventListener('keypress', function(e) {
                if (e.key === 'Enter') {
                    applyFilter();
                }
            });
            
            addPatientBtn.addEventListener('click', addPatient);
            
            modalClose.addEventListener('click', function() {
                patientModalOverlay.style.display = 'none';
            });
            
            cancelBtn.addEventListener('click', function() {
                patientModalOverlay.style.display = 'none';
            });
            
            saveBtn.addEventListener('click', savePatient);
            
            deleteModalClose.addEventListener('click', function() {
                deleteModalOverlay.style.display = 'none';
            });
            
            cancelDeleteBtn.addEventListener('click', function() {
                deleteModalOverlay.style.display = 'none';
            });
            
            confirmDeleteBtn.addEventListener('click', confirmDelete);
            
            // 每页显示数量选择器事件
            pageSizeSelector.addEventListener('change', function() {
                pageSize = parseInt(pageSizeSelector.value);
                currentPage = 1;
                renderTable();
            });
            
            // 点击弹窗外部关闭弹窗
            patientModalOverlay.addEventListener('click', function(e) {
                if (e.target === patientModalOverlay) {
                    patientModalOverlay.style.display = 'none';
                }
            });
            
            deleteModalOverlay.addEventListener('click', function(e) {
                if (e.target === deleteModalOverlay) {
                    deleteModalOverlay.style.display = 'none';
                }
            });

            // 用户下拉菜单
            const userSection = document.getElementById('userSection');
            const userDropdown = document.getElementById('userDropdown');
            
            if (userSection && userDropdown) {
                userSection.addEventListener('click', function(e) {
                    e.stopPropagation();
                    const isOpen = userDropdown.style.display === 'block';
                    userDropdown.style.display = isOpen ? 'none' : 'block';
                });

                document.addEventListener('click', function() {
                    userDropdown.style.display = 'none';
                });
            }

            // 年龄和出生日期联动
            patientAgeInput.addEventListener('change', function() {
                const age = parseInt(patientAgeInput.value);
                if (!isNaN(age)) {
                    const today = new Date();
                    const birthYear = today.getFullYear() - age;
                    birthDateInput.value = `${birthYear}-01-01`;
                }
            });
            
            birthDateInput.addEventListener('change', function() {
                const birthDate = new Date(birthDateInput.value);
                if (!isNaN(birthDate.getTime())) {
                    const today = new Date();
                    const age = today.getFullYear() - birthDate.getFullYear();
                    patientAgeInput.value = age;
                }
            });

            // 初始化表格
            renderTable();
        });
    </script>
</body>
</html>
